Inside Macintosh: QuickTime Components

Previous | Chapter Top | Chapter Contents | Next

Controlling Compressed Source Devices

Some video digitizer components may provide functions that allow applications to work with digitizing devices that can provide compressed image data directly. Such devices allow applications to retrieve compressed image data without using the Image Compression Manager. However, in order to display images from the compressed data stream, there must be an appropriate decompressor component available to decompress the image data.

Video digitizers that can support compressed source devices set the digiOutDoesCompress flag to 1 in their capability flags (see "Capability Flags," for more information about these flags).

Applications can use the VDGetCompressionTypes function to determine the image-compression capabilities of a video digitizer. The VDSetCompression function allows applications to set some parameters that govern image compression.

Applications control digitization by calling the VDCompressOneFrameAsync function, which instructs the video digitizer to create one frame of compressed image data. The VDCompressDone function returns that frame. When an application is done with a frame, it calls the VDReleaseCompressBuffer function to free the buffer. An application can force the digitizer to place a key frame into the sequence by calling the VDResetCompressSequence function. Applications can turn compression on and off by calling VDSetCompressionOnOff .

Applications can obtain the digitizer's image description structure by calling the VDGetImageDescription function. Applications can set the digitizer's time base by calling the VDSetTimeBase function.

All of the digitizing functions described in this section support only asynchronous digitization. That is, the video digitizer works independently to digitize each frame. Applications are free to perform other work while the digitizer works on each frame.

The video digitizer component manages its own buffer pool for use with these functions. In this respect, these functions differ from the other video digitizer functions that support asynchronous digitization (see "Controlling Digitization," for more information about these functions).

VDGetCompressionTypes

The VDGetCompressionTypes function allows an application to determine the image-compression capabilities of the video digitizer.

pascal VideoDigitizerError VDGetCompressionTypes
                                         (VideoDigitizerComponent ci,
                                         VDCompressionListHandle h);
ci
Identifies an application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.
h
Identifies a handle to receive the compression information. The video digitizer returns information about its capabilities by formatting one or more compression list structures in this handle (the format and content of the compression list structure are discussed later). If the digitizer supports more than one compression type, it creates an array of structures in this handle.
The video digitizer sizes this handle appropriately. It is the application's responsibility to dispose of this handle when it is done with it.

DESCRIPTION

The video digitizer places its preferred, or default, compression options in the first compression list structure in the returned array.

Note that there must be a decompressor component of the appropriate type available in the system if an application is to display images from a compressed image sequence.

The VDCompressionList data type defines the format and content of the compression list structure:

typedef struct VDCompressionList {
    CodecComponent          codec;              /* component ID */
    CodecType               cType;              /* compressor type */
    Str63                   typeName;           /* compression algorithm */
    Str63                   name;               /* compressor name string */
    long                    formatFlags;        /* data format flags */
    long                    compressFlags;      /* capabilities flags */
    long                    reserved;           /* set to 0 */
} VDCompressionList, *VDCompressionListPtr, **VDCompressionListHandle;
codec
Contains the component identifier for the video digitizer's compressor component. Some video digitizers may also implement their image-compression capabilities in an Image Compression Manager compressor component. In this case, the digitizer may allow the application to connect to and use the compressor. If so, the digitizer provides the compressor component's identifier here. If not, the digitizer sets this field to nil .
cType
Identifies the compression algorithm supported by the video digitizer. See the chapter "Image Compression Manager" in Inside Macintosh: QuickTime for a list of values supported by Apple.
typeName
Contains a text string that identifies the compression algorithm. An application may display this string to the user to identify the type of image compression being performed. See the chapter "Image Compression Manager" in Inside Macintosh: QuickTime for a list of values supported by Apple.
name
Specifies the name of the compressor. The developer of the video digitizer assigns this name. An application may display this string to the user.
formatFlags
Contains flags that describe the data formats supported by the video digitizer. Typically, these flags are of interest only to developers of video digitizers and image compressors. See the chapter "Image Compressor Components" in this book for more information.
compressFlags
Contains flags that describe the compression capabilities of the video digitizer. Typically, these flags are of interest only to developers of video digitizers and image compressors. See the chapter "Image Compressor Components" in this book for more information.
reserved
Reserved for Apple. Always set to 0.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

VDSetCompression

The VDSetCompression function allows applications to specify some compression parameters.

pascal VideoDigitizerError VDSetCompression
                                         (VideoDigitizerComponent ci,
                                          OSType compressType, short depth,
                                          Rect *bounds, CodecQ spatialQuality,
                                          CodecQ temporalQuality,
                                          long keyFrameRate);
ci
Identifies the application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.
compressType
Specifies a compressor type. This value corresponds to the component subtype of the compressor component. See the chapter "Image Compression Manager" in Inside Macintosh: QuickTime for more information about compressor types and for valid values for this parameter.
depth
Specifies the depth at which the image is likely to be viewed. Compressors may use this as an indication of the color or grayscale resolution of the image. Values of 1, 2, 4, 8, 16, 24, and 32 indicate the number of bits per pixel for color images. Values of 33, 34, 36, and 40 correspond to 1-bit, 2-bit, 4-bit, and 8-bit grayscale images.
bounds
Contains a pointer to a rectangle that defines the desired boundaries of the compressed image.
spatialQuality
Indicates the desired image quality for each frame in the sequence. See the chapter "Image Compression Manager" in Inside Macintosh: QuickTime for valid compression quality values.
temporalQuality
Indicates the desired temporal quality for the sequence as a whole. See the chapter "Image Compression Manager" in Inside Macintosh: QuickTime for valid compression quality values.
keyFrameRate
Specifies the maximum number of frames to allow between key frames. This value defines the minimum rate at which key frames are to appear in the compressed sequence; however, the video digitizer may insert key frames more often than an application specifies. If the application requests no temporal compression (that is, the application set the temporalQuality parameter to 0), the video digitizer ignores this parameter.
For more information about key frames, see the chapter "Image Compression Manager" in Inside Macintosh: QuickTime .

DESCRIPTION

An application may use the VDSetCompression function to control the parameters that govern image compression. An application may change the compressor type, image depth, and boundary rectangle parameters only when the digitizer is stopped. However, if an application sets these three parameters (that is, the compressType , depth , and bounds parameters) to 0, it may work with the other parameters while digitization is active. This allows an application to vary the data rate during digitization.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

qtParamErr

-2202

Invalid parameter value

VDSetCompressionOnOff

The VDSetCompressionOnOff function allows an application to start and stop compression by digitizers that can deliver either compressed or uncompressed image data.

pascal VideoDigitizerError VDSetCompressionOnOff
                                         (VideoDigitizerComponent ci,
                                          Boolean state);
ci
Identifies the application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.
state
Contains a Boolean value that indicates whether to enable or disable compression. Applications set this parameter to true to enable compression. Setting it to false disables compression.

DESCRIPTION

This is a required function for digitizers that are going to perform compression. These digitizers have their digiOutDoesCompress capability flag set to 1 and their digiOutDoesCompressOnly flag set to 0. Digitizers that support this capability typically deliver uncompressed image data in addition to the compressed data stream; the uncompressed data is ready for display.

Digitizers that only provide compressed data have their digiOutDoesCompressOnly flag set to 1, rather than 0. These digitizers may either ignore this function or return a nonzero result code.

Applications must call this function before they call either VDSetCompression or VDCompressOneFrameAsync . This allows the video digitizer to prepare for the operation.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

VDCompressOneFrameAsync

The VDCompressOneFrameAsync function instructs the video digitizer to digitize and compress a single frame of image data. Because the component performs this action asynchronously, the application is free to do other things while the digitizer works on the image.

pascal VideoDigitizerError VDCompressOneFrameAsync
                                         (VideoDigitizerComponent ci);
ci
Identifies the application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.

DESCRIPTION

An application can determine when the digitizer is done with the frame by calling the VDCompressDone function, which is discussed next.

Unlike the VDGrabOneFrameAsync function (discussed on VDGrabOneFrameAsync ), the video digitizer handles all details of managing data buffers.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

VDCompressDone

The VDCompressDone function allows an application to determine whether the video digitizer has finished digitizing and compressing a frame of image data. An application starts the digitizing process by calling the VDCompressOneFrameAsync function, which was just discussed.

pascal VideoDigitizerError VDCompressDone
                                         (VideoDigitizerComponent ci,
                                          Boolean *done, Ptr *theData,
                                          long *dataSize,
                                          UInt8 *similarity,
                                          TimeRecord *t);
ci
Identifies the application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.
done
Contains a pointer to a Boolean value. Applications set this value to true when they are done, and set it to false if the operation is incomplete.
theData
Contains a pointer to a field that is to receive a pointer to the compressed image data. The digitizer returns a pointer that is valid in the application's current memory mode.
The digitizer allocates the memory into which it places the digitized data. An application must call the VDReleaseCompressBuffer function to dispose of this memory; this function is discussed next.
dataSize
Contains a pointer to a field to receive a value indicating the number of bytes of compressed image data.
similarity
Contains a pointer to a field to receive an indication of the relative similarity of this image to the previous image in a sequence. A value of 0 indicates that the current frame is a key frame in the sequence. A value of 255 indicates that the current frame is identical to the previous frame. Values from 1 through 254 indicate relative similarity, ranging from very different (1) to very similar (254). This field is only filled in if the temporal quality passed in with the VDSetCompression function (described on VDSetCompression ) is not 0--that is, if it is not frame-differenced.
t
Contains a pointer to a time record. When the operation is complete, the digitizer fills in this structure with information indicating when the frame was grabbed. The time value stored in this structure is in the time base that the application sets with the VDSetTimeBase function (see VDSetTimeBase for more information about this function). The format and content of this structure are discussed in the chapter "Movie Toolbox" in Inside Macintosh: QuickTime .

DESCRIPTION

An application can determine when the digitizer is done with the frame by calling the VDCompressDone function. When the digitizer is done, it sets the Boolean value referred to by the done parameter to true , and then returns information about the digitized and compressed frames via the theData , dataSize , similarity , and t parameters.

If the digitizer is not yet done, it sets the Boolean value to false . In this case, the digitizer does not return any other information.

Note that the digitizer is careful to return the frames in temporal order, and to avoid returning two frames with the same time value (unless the rate is set to 0).

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

SEE ALSO

Applications must use the VDReleaseCompressBuffer function to free the memory that contains the compressed image data. This function is described in the next section.

VDReleaseCompressBuffer

The VDReleaseCompressBuffer function allows an application to free a buffer received from the VDCompressDone function.

pascal VideoDigitizerError VDReleaseCompressBuffer
                                         (VideoDigitizerComponent ci,
                                          Ptr bufferAddr);
ci
Identifies the application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.
bufferAddr
Points to the location of the buffer to be released. This address must correspond to a buffer address that the application obtained from the VDCompressDone function (discussed in the previous section).

DESCRIPTION

Once an application frees the buffer, the video digitizer is able to use the buffer for other images. Applications should try to free these buffers as quickly as possible, so that the video digitizer can make optimum use of its buffer, and thereby support higher frame rates.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

VDGetImageDescription

The VDGetImageDescription function allows an application to retrieve an image description structure from a video digitizer.

pascal VideoDigitizerError VDGetImageDescription
                                         (VideoDigitizerComponent ci,
                                          ImageDescriptionHandle desc);
ci
Identifies the application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.
desc
Specifies a handle. The video digitizer fills this handle with an Image Compression Manager image description structure containing information about the digitizer's current compression settings. The digitizer resizes the handle appropriately. It is the application's responsibility to dispose of this handle.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

SEE ALSO

See the chapter "Image Compression Manager" in Inside Macintosh: QuickTime for a complete description of the image description structure.

VDResetCompressSequence

The VDResetCompressSequence function allows an application to force the video digitizer to insert a key frame into a temporally compressed image sequence.

pascal VideoDigitizerError VDResetCompressSequence
                                         (VideoDigitizerComponent ci);
ci
Identifies the application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.

DESCRIPTION

After an application calls this function, the digitizer ensures that the next frame returned to the application is a key frame.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

SEE ALSO

An application can control the rate at which the digitizer inserts key frames by calling the VDSetCompression function, which is discussed beginning on VDSetCompression .

VDSetTimeBase

The VDSetTimeBase function allows an application to establish the video digitizer's time coordinate system.

pascal VideoDigitizerError VDSetTimeBase
                                         (VideoDigitizerComponent ci,
                                          TimeBase t);
ci
Identifies the application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.
t
Specifies the video digitizer's new time base.

DESCRIPTION

Video digitizers return all time information in relation to the specified time base. For example, whenever a digitizer returns a compressed frame from its VDCompressDone function, it returns time information relating to the time when the frame was digitized and compressed. This time information is expressed in the time base that the application specifies with this function.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next